package com.mxpio.erp.common.quality.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpioframework.jpa.annotation.DictAble;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.User;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "V_MB_ERP_INSPECTION_BILL_COMPLETE_INSPECTION_DAY")
@Schema(description="当日完成检验")
public class VEInspectionBillCompleteInspectionDay implements DictAble, Serializable {
    private static final long serialVersionUID = 1L;


    @Id
    @Column(name = "BIZ_NO_", updatable = false)
    @Schema(description = "质检单号")
    private String bizNo;


    @Column(name = "TYPE_")
    @Schema(description = "类型")
    private String type;

    @Column(name = "TEST_RESULT_")
    @Schema(description = " 检验结论")
    @Dict(dicCode = "MB_QUALITY_CHECK_RESULT")//0不合格，1合格
    private String testResult;

    @Column(name = "INSPECTION_FINISH_TIME_")
    @Schema(description = "检验结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date inspectionFinishTime;

    /**
     * 因为通知单确认后同步生成的质检单， 所以说取质检单的创建人和创建时间充当通知单的确认人和确认时间
     */
    @Column(name = "ACCEPTANCE_BY_")
    @Schema(description = "通知单确认人")//检验员
    @Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
    private String acceptanceBy;

    @Column(name = "ACCEPTANCE_TIME_")//接收日期
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @Schema(description = "通知单确认时间时间")
    private Date acceptanceTime;

    @Transient
    private Map<String, String> textMap;
    public String putText(String key, String value) {
        if (textMap == null) {
            textMap = new HashMap<>();
        }
        return textMap.put(key, value);
    }
}
